#include<bits/stdc++.h>
using namespace std;
int t,n,m,L,V;
const int N = 1e5 + 5;
int d[N],v[N],a[N],p[N],f[N],s[N],e[N],chafen[1000005],b[1000005];
bool isa,isb,isc;
#define atspeed(v0,a,s) sqrt(v0*v0+a*2*s) // max speed
#define tospeed(V1,V0,a) (V1*V1-V0*V0)/(2*a) // distance to max speed
int cei(double(b)){
    if(b==ceil(b))return b+1;
    return ceil(b);
}
void solve()
{
    memset(chafen,0,sizeof chafen);
    cin >> n >> m >> L >> V;
    for(int i=1;i<=n;i++) {
        cin >> d[i] >> v[i] >> a[i];
        if(a[i]==0){
            isa=1;
        }
        else if(a[i]>0){
            isb=1;
        }
        else if(a[i]<0){
            isc=1;
        }
    }
    for(int i=1;i<=m;i++)cin>>p[i],b[p[i]]++;
    if(isa+isb+isc==1){
        if(isa){
            for(int i=1;i<=n;i++){
                if(v[i]>V){
                    chafen[d[i]]++;
                }
            }
            int maxx=0;
            for(int i=1;i<=m;i++){
                maxx=max(maxx,p[i]);
            }
            int cnt=0;
            for(int i=1;i<=maxx;i++){
                cnt+=chafen[i];
            }
            cout<<cnt<<' '<<m-1<<'\n';
        }
        else if(isb){
            for(int i=1;i<=n;i++){
                if(v[i]>V){
                    chafen[d[i]]++;
                }
                else if(int(d[i]+cei(tospeed(V,v[i],a[i])))<=L){
                    chafen[int(d[i]+cei(tospeed(V,v[i],a[i])))]++;
                }
            }
            int maxx=0;
            for(int i=1;i<=m;i++){
                maxx=max(maxx,p[i]);
            }
            int cnt=0;
            for(int i=1;i<=maxx;i++){
                cnt+=chafen[i];
            }
            cout<<cnt<<' '<<m-1<<'\n';
        }
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
